/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package onpu_dms_xls.kernel.common.pdf.composite;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author snbm
 */
public class ExtractCompositeComponent extends ExtractComponent {
    private List<ExtractComponent> components;

    public ExtractCompositeComponent (String n){
        super(n);
//        System.out.println("PDF_ExtractCompositeComponent constructor n="+n);
    }

    @Override
    public void print() {
//        System.out.println("PDF_ExtractCompositeComponent print ");
        for (ExtractComponent c : getComponents()){
            c.print();
        }
    }

    @Override
    public void printToPDFWriter(PDF_ExtractWriter pdf_ew){
        for (ExtractComponent c : getComponents()){
            c.printToPDFWriter(pdf_ew);
        }
    }

    public void addComponent(ExtractComponent c){
        getComponents().add(c);
    }

    public void removeComponent (ExtractComponent c){
        getComponents().remove(c);
    }

    @Override
    public Iterator<ExtractComponent> getIterator(){
        return getComponents().iterator();
    }

    private List<ExtractComponent> getComponents(){
        if (components == null){
            components = new ArrayList<ExtractComponent>();
        }
        return components;
    }
}
